package com.ruoyi.baseSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.baseSys.domain.MBuildingManage;
import com.ruoyi.baseSys.service.IMBuildingManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 楼栋管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/baseSys/buildingmanage")
public class MBuildingManageController extends BaseController
{
    @Autowired
    private IMBuildingManageService mBuildingManageService;

    /**
     * 查询楼栋管理列表
     */
    @PreAuthorize("@ss.hasPermi('baseSys:buildingmanage:list')")
    @GetMapping("/list")
    public TableDataInfo list(MBuildingManage mBuildingManage)
    {
        startPage();
        List<MBuildingManage> list = mBuildingManageService.selectMBuildingManageList(mBuildingManage);
        return getDataTable(list);
    }

    /**
     * 导出楼栋管理列表
     */
    @PreAuthorize("@ss.hasPermi('baseSys:buildingmanage:export')")
    @Log(title = "楼栋管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MBuildingManage mBuildingManage)
    {
        List<MBuildingManage> list = mBuildingManageService.selectMBuildingManageList(mBuildingManage);
        ExcelUtil<MBuildingManage> util = new ExcelUtil<MBuildingManage>(MBuildingManage.class);
        util.exportExcel(response, list, "楼栋管理数据");
    }

    /**
     * 获取楼栋管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('baseSys:buildingmanage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mBuildingManageService.selectMBuildingManageById(id));
    }
    //查询小区信息



    /**
     * 新增楼栋管理
     */
    @PreAuthorize("@ss.hasPermi('baseSys:buildingmanage:add')")
    @Log(title = "楼栋管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MBuildingManage mBuildingManage)
    {
        return toAjax(mBuildingManageService.insertMBuildingManage(mBuildingManage));
    }

    /**
     * 修改楼栋管理
     */
    @PreAuthorize("@ss.hasPermi('baseSys:buildingmanage:edit')")
    @Log(title = "楼栋管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MBuildingManage mBuildingManage)
    {
        return toAjax(mBuildingManageService.updateMBuildingManage(mBuildingManage));
    }

    /**
     * 删除楼栋管理
     */
    @PreAuthorize("@ss.hasPermi('baseSys:buildingmanage:remove')")
    @Log(title = "楼栋管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mBuildingManageService.deleteMBuildingManageByIds(ids));
    }
    //获取小区楼栋信息
    @GetMapping(value = "/getbuildingllist/{id}")
    public AjaxResult getbuildinglist(@PathVariable("id") Long id)
    {
        return success(mBuildingManageService.getBuildingList(id));
    }
}
